class Solution(object):
    def majorityElement(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        counter = {}
        n = len(nums)

        for v in nums:
            if v not in counter:
                counter[v] = 1
            else:
                counter[v] += 1

            if counter[v] > n // 2:
                return v

s = Solution()
print(s.majorityElement([1]))
print(s.majorityElement([3,2,3]))
print(s.majorityElement([2,2,1,1,1,2,2]))

